package com.ruoyi.roomDetail.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.roomDetail.domain.OrderRoomDetail;
import com.ruoyi.roomDetail.service.IOrderRoomDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 客房订单详情信息Controller
 * 
 * @author ruoyi
 * @date 2025-06-05
 */
@RestController
@RequestMapping("/ruoyi/roomDetail")
public class OrderRoomDetailController extends BaseController
{
    @Autowired
    private IOrderRoomDetailService orderRoomDetailService;

    /**
     * 查询客房订单详情信息列表
     */
    @PreAuthorize("@ss.hasPermi('ruoyi:roomDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(OrderRoomDetail orderRoomDetail)
    {
        startPage();
        List<OrderRoomDetail> list = orderRoomDetailService.selectOrderRoomDetailList(orderRoomDetail);
        return getDataTable(list);
    }

    /**
     * 导出客房订单详情信息列表
     */
    @PreAuthorize("@ss.hasPermi('ruoyi:roomDetail:export')")
    @Log(title = "客房订单详情信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OrderRoomDetail orderRoomDetail)
    {
        List<OrderRoomDetail> list = orderRoomDetailService.selectOrderRoomDetailList(orderRoomDetail);
        ExcelUtil<OrderRoomDetail> util = new ExcelUtil<OrderRoomDetail>(OrderRoomDetail.class);
        util.exportExcel(response, list, "客房订单详情信息数据");
    }

    /**
     * 获取客房订单详情信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('ruoyi:roomDetail:query')")
    @GetMapping(value = "/{detailId}")
    public AjaxResult getInfo(@PathVariable("detailId") Long detailId)
    {
        return success(orderRoomDetailService.selectOrderRoomDetailByDetailId(detailId));
    }

    /**
     * 新增客房订单详情信息
     */
    @PreAuthorize("@ss.hasPermi('ruoyi:roomDetail:add')")
    @Log(title = "客房订单详情信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderRoomDetail orderRoomDetail)
    {
        return toAjax(orderRoomDetailService.insertOrderRoomDetail(orderRoomDetail));
    }

    /**
     * 修改客房订单详情信息
     */
    @PreAuthorize("@ss.hasPermi('ruoyi:roomDetail:edit')")
    @Log(title = "客房订单详情信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderRoomDetail orderRoomDetail)
    {
        return toAjax(orderRoomDetailService.updateOrderRoomDetail(orderRoomDetail));
    }

    /**
     * 删除客房订单详情信息
     */
    @PreAuthorize("@ss.hasPermi('ruoyi:roomDetail:remove')")
    @Log(title = "客房订单详情信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{detailIds}")
    public AjaxResult remove(@PathVariable Long[] detailIds)
    {
        return toAjax(orderRoomDetailService.deleteOrderRoomDetailByDetailIds(detailIds));
    }
}
